package mazegame;

import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.Map;
import java.util.Map.Entry;

public class MazeUtil {
	
	public static String log(String entry, String curLog)
    {
            return curLog + entry + "\n";
    }
	
	public static <T, E> T getKeyByValue(Map<T, E> map, E value) {
	    for (Entry<T, E> entry : map.entrySet()) {
	        if (value.equals(entry.getValue())) {
	            return entry.getKey();
	        }
	    }
	    return null;
	}
	
	public static String getOwnHostName(){
		String hostAddr = "127.0.0.1";
		try
        {            
			InetAddress addr = InetAddress.getLocalHost();
            String hostname = addr.getHostName();
            hostAddr = addr.getHostAddress();
            System.out.println(addr.getHostAddress());
            System.out.println(hostname);
        }catch(UnknownHostException e)
        {
        	System.out.println("UnknownHostException");
        	return hostAddr;
        }	
		
		return hostAddr;
	}

}
